<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Converts a MySQL connection handle into a mysqlnd connection handle</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.mysqlnd-uh.html">Mysqlnd_uh 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-uh-set-connection-proxy.html">mysqlnd_uh_set_connection_proxy</a></div>
 <div class="up"><a href="ref.mysqlnd-uh.html">Mysqlnd_uh 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mysqlnd-uh-convert-to-mysqlnd" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqlnd_uh_convert_to_mysqlnd</h1>
  <p class="verinfo">(PECL mysqlnd-uh &gt;= 1.0.0-alpha)</p><p class="refpurpose"><span class="refname">mysqlnd_uh_convert_to_mysqlnd</span> &mdash; <span class="dc-title">Converts a MySQL connection handle into a mysqlnd connection handle</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> 
   <span class="methodname"><strong>mysqlnd_uh_convert_to_mysqlnd</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.mysqli.html" class="type mysqli">mysqli</a></span> <code class="parameter reference">&$mysql_connection</code></span>
   )</div>

  <p class="para rdfs-comment">
   Converts a MySQL connection handle into a mysqlnd connection handle.
   After conversion you can execute mysqlnd library calls on the connection handle.
   This can be used to access mysqlnd functionality not made available
   through user space API calls.
  </p>
  <p class="para">
   The function can be disabled with
   <em><a href="mysqlnd-uh.configuration.html#ini.mysqlnd-uh.enable" class="link">mysqlnd_uh.enable</a></em>.
   If <em><a href="mysqlnd-uh.configuration.html#ini.mysqlnd-uh.enable" class="link">mysqlnd_uh.enable</a></em>
   is set to <strong><code>FALSE</code></strong> the function will not install the proxy and
   always return <strong><code>TRUE</code></strong>. Additionally, an error of the
   type <em>E_WARNING</em> may be emitted. The error message may
   read like <em>PHP Warning:  mysqlnd_uh_convert_to_mysqlnd(): (Mysqlnd User Handler)
   The plugin has been disabled by setting the configuration parameter mysqlnd_uh.enable = false.
   You are not allowed to call this function [...]</em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">MySQL connection handle</code></em></dt>

    <dd>

     <p class="para">
      A MySQL connection handle of type mysql, mysqli or PDO_MySQL.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A mysqlnd connection handle.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.4.0</td>
       <td>
        The <em><code class="parameter">mysql_connection</code></em> parameter can now be of type
        <em>mysql</em>, <em>PDO_MySQL</em>, or <em>mysqli</em>.
        Before, only the <em>mysqli</em> type was allowed.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1900">
    <p><strong>Example #1 <span class="function"><strong>mysqlnd_uh_convert_to_mysqlnd()</strong></span> example</strong></p>
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;PDO&nbsp;user&nbsp;API&nbsp;gives&nbsp;no&nbsp;access&nbsp;to&nbsp;connection&nbsp;thread&nbsp;id&nbsp;*/<br /></span><span style="color: #0000BB">$mysql_connection&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysql:host=localhost;dbname=test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"root"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Convert&nbsp;PDO&nbsp;MySQL&nbsp;handle&nbsp;to&nbsp;mysqlnd&nbsp;handle&nbsp;*/<br /></span><span style="color: #0000BB">$mysqlnd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysqlnd_uh_convert_to_mysqlnd</span><span style="color: #007700">(</span><span style="color: #0000BB">$mysql_connection</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Create&nbsp;Proxy&nbsp;to&nbsp;call&nbsp;mysqlnd&nbsp;connection&nbsp;class&nbsp;methods&nbsp;*/<br /></span><span style="color: #0000BB">$obj&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MySQLndUHConnection</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">/*&nbsp;Call&nbsp;mysqlnd_conn::get_thread_id&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getThreadId</span><span style="color: #007700">(</span><span style="color: #0000BB">$mysqlnd</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">/*&nbsp;Use&nbsp;SQL&nbsp;to&nbsp;fetch&nbsp;connection&nbsp;thread&nbsp;id&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$mysql_connection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;CONNECTION_ID()"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">fetchAll</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
int(27054)
array(1) {
  [0]=&gt;
  array(2) {
    [&quot;CONNECTION_ID()&quot;]=&gt;
    string(5) &quot;27054&quot;
    [0]=&gt;
    string(5) &quot;27054&quot;
  }
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysqlnd-uh-convert-to-mysqlnd-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
     <em><a href="mysqlnd-uh.configuration.html#ini.mysqlnd-uh.enable" class="link">mysqlnd_uh.enable</a></em>
    </li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.mysqlnd-uh.html">Mysqlnd_uh 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-uh-set-connection-proxy.html">mysqlnd_uh_set_connection_proxy</a></div>
 <div class="up"><a href="ref.mysqlnd-uh.html">Mysqlnd_uh 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
